﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;

namespace Scoot.UI.Conversation
{
    /// <summary>
    /// Interaction logic for ConversationWindow.xaml
    /// </summary>
    public partial class ConversationWindow : Window
    {
        private bool isAppClosing=false;
        public ConversationWindow()
        {
            InitializeComponent();
            conversationControl.Hide_Window += new ConversationControl.WindowHideEventHandler(conversationControl_Hide_Window);
        }

        void conversationControl_Hide_Window()
        {
            this.Hide();
        }
        public void addMessage(string message, int uin)
        {
            this.Show();
            conversationControl.addMessage(message, uin);
        }

        public void openTab(int uin)
        {
            this.Show();
            this.Activate();
            
            conversationControl.openTab(uin);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if(!isAppClosing)
                {
                e.Cancel = true;
                this.Hide();
            }
        }
        public void Dispose()
        {
            isAppClosing = true;
            this.Close();
        }
    }
}
